SPB Git

Repository Public

route.ts 2.7 KB 61 lines typescript

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : Vrai-Prix8 * File             : src/app/api/admin/cost/sync/[connector]/route.ts9 * Module           : app10 * Repository       : https://git.spboucher.ai/vrai-prix11 * Created          : 2026-09-0812 * Last Modified    : 2026-09-0813 *14 * Author           : Simon-Pierre Boucher15 * Position         : Professor of Finance16 * Institution      : Université du Québec en Outaouais (UQO)17 * Organization     : SP Boucher18 * Website          : https://spboucher.ai19 * Git              : https://git.spboucher.ai20 *21 * Preferred Contact: contact@spboucher.ai22 * Development      : dev@spboucher.ai23 * Support          : support@spboucher.ai24 * Security/Admin   : admin@spboucher.ai25 *26 * Copyright (c) 202627 * Simon-Pierre Boucher28 * All rights reserved where applicable. This file is governed by the29 * applicable project license, copyright notices and relevant law.30 * Existing third-party rights and notices remain unaffected.31 *32 * License          : None specified (no license file in this repository)33 *34 * Do not embed credentials, private keys, access tokens,35 * certificates or confidential personal information.36 *37 * =============================================================================38 * END OF SP BOUCHER SOURCE HEADER39 * =============================================================================40 */4142// Vrai-Prix — admin méthode du coût : déclenche une synchronisation en arrière-plan (jeton requis).43import { NextRequest, NextResponse } from "next/server";44import { adminAuth, launchConnector } from "@/lib/cost/connectors/admin";45import { isRunnable, IMPORT_ONLY } from "@/lib/cost/connectors/registry";4647export const runtime = "nodejs";48export const maxDuration = 25;4950export async function POST(req: NextRequest, { params }: { params: Promise<{ connector: string }> }) {51  const denied = adminAuth(req);52  if (denied) return denied;53  const { connector } = await params;54  if (IMPORT_ONLY.includes(connector as never)) return NextResponse.json({ error: `${connector} : import manuel seulement (POST /api/admin/cost/benchmarks/import)` }, { status: 400 });55  if (!isRunnable(connector)) return NextResponse.json({ error: "connecteur inconnu" }, { status: 404 });56  const force = req.nextUrl.searchParams.get("force") === "1";57  const items = req.nextUrl.searchParams.get("items")?.split(",").map((s) => s.trim()).filter(Boolean);58  const r = launchConnector(connector, force, items);59  return NextResponse.json({ connector, ...r }, { status: r.started ? 202 : 409 });60}61
Files main
Menu

Theme